<?php

	include '../common.php';

	$json = json_decode(file_get_contents('php://input'));
	
	$userID = $json->{'user_id'};
	$movieID = $json->{'movie_id'};
	
	$conn = linkMySql();
	
	if ($userID == "0") {
		$sql = "select " . MOVIE_DETAILS_TABLE.".".SEA_PICTURES . " , "
				. MIDDLE_MOVIE_TABLE.".".IS_COLLECTION . " from " .MOVIE_DETAILS_TABLE . ", " .MIDDLE_MOVIE_TABLE
				. " where " . MOVIE_DETAILS_TABLE.".".RESUME_MOVIE_ID . " = $movieID";
	} else {
		$sql = "select " . MOVIE_DETAILS_TABLE.".".SEA_PICTURES . " , "
				. MIDDLE_MOVIE_TABLE.".".IS_COLLECTION . " from " .MOVIE_DETAILS_TABLE . ", " .MIDDLE_MOVIE_TABLE
				. " where " . MIDDLE_MOVIE_TABLE.".".MIDDLE_USER_ID . " = $userID and "
						. MOVIE_DETAILS_TABLE.".".RESUME_MOVIE_ID . " = $movieID";
	}

	$query = mysqli_query($conn, $sql);
	$result = mysqli_fetch_assoc($query);
	$array = array("tag"=>MOVIE_DETAIL, "sea_pictures"=>$result);
	echo  json_encode($array);die;
?>